/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Daniel Cruz
 */
@Entity
@Table(name = "telefono_persona")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TelefonoPersona.findAll", query = "SELECT t FROM TelefonoPersona t"),
    @NamedQuery(name = "TelefonoPersona.findByTelefonoPrs", query = "SELECT t FROM TelefonoPersona t WHERE t.telefonoPersonaPK.telefonoPrs = :telefonoPrs"),
    @NamedQuery(name = "TelefonoPersona.findByPrsIdentificacion", query = "SELECT t FROM TelefonoPersona t WHERE t.telefonoPersonaPK.prsIdentificacion = :prsIdentificacion")})
public class TelefonoPersona implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected TelefonoPersonaPK telefonoPersonaPK;
    @JoinColumn(name = "prs_identificacion", referencedColumnName = "prs_identificacion", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private BPersona bPersona;

    public TelefonoPersona() {
    }

    public TelefonoPersona(TelefonoPersonaPK telefonoPersonaPK) {
        this.telefonoPersonaPK = telefonoPersonaPK;
    }

    public TelefonoPersona(String telefonoPrs, String prsIdentificacion) {
        this.telefonoPersonaPK = new TelefonoPersonaPK(telefonoPrs, prsIdentificacion);
    }

    public TelefonoPersonaPK getTelefonoPersonaPK() {
        return telefonoPersonaPK;
    }

    public void setTelefonoPersonaPK(TelefonoPersonaPK telefonoPersonaPK) {
        this.telefonoPersonaPK = telefonoPersonaPK;
    }

    public BPersona getBPersona() {
        return bPersona;
    }

    public void setBPersona(BPersona bPersona) {
        this.bPersona = bPersona;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (telefonoPersonaPK != null ? telefonoPersonaPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TelefonoPersona)) {
            return false;
        }
        TelefonoPersona other = (TelefonoPersona) object;
        if ((this.telefonoPersonaPK == null && other.telefonoPersonaPK != null) || (this.telefonoPersonaPK != null && !this.telefonoPersonaPK.equals(other.telefonoPersonaPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.TelefonoPersona[ telefonoPersonaPK=" + telefonoPersonaPK + " ]";
    }
    
}
